﻿
var myTree = [
    {
        "id": 1,
        "pid": 0,
        "name": "仓储物流科",
    },
    {
        "id": 2,
        "pid": 1,
        "name": "原材料罐区",
    },
    {
        "id": 3,
        "pid": 0,
        "name": "动力车间",
    },
    {
        "id": 4,
        "pid": 3,
        "name": "煤制氢装置",
    }
];

function randomTreeNode(tree, pid, b) {
    var result = '';
    var tempArray = [];
    if (!b) {
        var idArray = [];
        var pidArray = [];
        tree.forEach(function (v, i) {
            if (pid) {
                if (pid == v.pid) {
                    idArray.push(v.id);
                    pidArray.push(v.pid);
                }
            }
            else {
                idArray.push(v.id);
                pidArray.push(v.pid);
            }
        })
        tempArray = idArray.filter(function (v) { return pidArray.indexOf(v) === -1 });
        result = tempArray[Math.floor(Math.random() * tempArray.length)] + '';
    }
    else {
        tree.forEach(function (v, i) {
            if (v.pid + '' == '0') {
                tempArray.push(v.id);
            }
        })
        result = tempArray[Math.floor(Math.random() * tempArray.length)] + '';
    }
    return result;
}

//<!--设备设施列表-->
var $EquipmenFacilities = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/EquipmenFacilities/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                var temp = [];
                for (var i = 0; i < $EquipmenFacilities.EquipmenFacilities.length; i++) {
                    temp.push($EquipmenFacilities.EquipmenFacilities[i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $EquipmenFacilities.EquipmenFacilities.splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/EquipmenFacilities/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($EquipmenFacilities.EquipmenFacilities.length == 0) {
                        $EquipmenFacilities.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var Device = p.model.Device;
                    var FunctionalPart = p.model.FunctionalPart;
                    var Sub_functionPart = p.model.Sub_functionPart;
                    var B_ComponentName = p.model.B_ComponentName;
                    var ExpectedFunction = p.model.ExpectedFunction;
                    var Malfunction = p.model.Malfunction;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    var TreeNode = p.model.TreeNode;
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;
                    var limitUsers2 = [];
                    for (var i = 0; i < $EquipmenFacilities.EquipmenFacilities.length; i++) {
                        var user = $EquipmenFacilities.EquipmenFacilities[i];
                       if (Device && user.Device.indexOf(Device) == -1)
                           continue;
                        if (FunctionalPart && user.FunctionalPart.indexOf(FunctionalPart) == -1)
                            continue;
                        if (Sub_functionPart && user.Sub_functionPart.indexOf(Sub_functionPart) == -1)
                            continue;
                        if (B_ComponentName && user.B_ComponentName.indexOf(B_ComponentName) == -1)
                            continue;
                        if (ExpectedFunction && user.ExpectedFunction.indexOf(ExpectedFunction) == -1)
                            continue;
                        if (Malfunction && user.Malfunction.indexOf(Malfunction) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                           user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);
                        limitUsers2.push(user);
                    }

                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/EquipmenFacilities/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$EquipmenFacilities.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/EquipmenFacilities/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$EquipmenFacilities.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].Device = thisuser.Device;
                        thisUsers[i].FunctionalPart = thisuser.FunctionalPart;
                        thisUsers[i].Sub_functionPart = thisuser.Sub_functionPart;
                        thisUsers[i].ExpectedFunction = thisuser.ExpectedFunction;
                        thisUsers[i].Malfunction = thisuser.Malfunction;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].B_ComponentName = thisuser.B_ComponentName;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$EquipmenFacilities.EquipmenFacilities.push({
                        id: thisuser.id,
                        Device: thisuser.Device,
                        FunctionalPart: thisuser.FunctionalPart,
                        Sub_functionPart: thisuser.Sub_functionPart,
                        B_ComponentName: thisuser.B_ComponentName,
                        ExpectedFunction: thisuser.ExpectedFunction,
                        Malfunction: thisuser.Malfunction,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: randomTreeNode(myTree)
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $EquipmenFacilities.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                Device: randomValue("23"),
                FunctionalPart: randomValue("ZYHD"),
                Sub_functionPart: randomValue("WXXM"),
                B_ComponentName: randomValue("GNBF"),
                ExpectedFunction: randomValue("ZGNBF"),
                Malfunction: randomValue("BUJIAN"),
                Risk: randomValue("22"),
                HazardousFactors: randomValue("19"),
                ControlRequirement: randomValue("20"),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}

//<!--检维修作业活动编辑-->
var $InspectionMaintenanceActivities = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/InspectionMaintenanceActivities/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                //$InspectionMaintenanceActivities.EquipmenFacilities = $InspectionMaintenanceActivities.EquipmenFacilities.filter(function (u) {
                //    return !delIDs.includes(u.id);
                //});

                var temp = [];
                for (var i = 0; i < $InspectionMaintenanceActivities.EquipmenFacilities .length; i++) {
                    temp.push($InspectionMaintenanceActivities.EquipmenFacilities [i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $InspectionMaintenanceActivities.EquipmenFacilities .splice(temp[i], 1);
                    }
                }

                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/InspectionMaintenanceActivities/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($InspectionMaintenanceActivities.EquipmenFacilities.length == 0) {
                        $InspectionMaintenanceActivities.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var JobModule = p.model.JobModule;
                    var MaintanenceProject = p.model.MaintanenceProject;
                    var JobActivity = p.model.JobActivity;

                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    var TreeNode = p.model.TreeNode;
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;

                    var limitUsers2 = [];
                    for (var i = 0; i < $InspectionMaintenanceActivities.EquipmenFacilities.length; i++) {
                        var user = $InspectionMaintenanceActivities.EquipmenFacilities[i];
                        if (JobModule && user.JobModule.indexOf(JobModule) == -1)
                            continue;
                        if (MaintanenceProject && user.MaintanenceProject.indexOf(MaintanenceProject) == -1)
                            continue;
                        if (JobActivity && user.JobActivity.indexOf(JobActivity) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);

                        limitUsers2.push(user);
                    }
                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/InspectionMaintenanceActivities/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$InspectionMaintenanceActivities.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/InspectionMaintenanceActivities/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$InspectionMaintenanceActivities.EquipmenFacilities;
                var cz = true;
               
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].JobModule = thisuser.JobModule;
                        thisUsers[i].MaintanenceProject = thisuser.MaintanenceProject;
                        thisUsers[i].JobActivity = thisuser.JobActivity;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$InspectionMaintenanceActivities.EquipmenFacilities.push({
                        id: thisuser.id,
                        JobModule: thisuser.JobModule,
                        MaintanenceProject: thisuser.MaintanenceProject,
                        JobActivity: thisuser.JobActivity,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $InspectionMaintenanceActivities.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                JobModule: randomValue('21'),
                MaintanenceProject: randomValue('WXXM'),
                JobActivity: randomValue('ZYHD'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}

//<!--操作程序列表-->
var $OperatingProcedures = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/OperatingProcedures/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                //$OperatingProcedures.EquipmenFacilities = $OperatingProcedures.EquipmenFacilities.filter(function (u) {
                //    return !delIDs.includes(u.id);
                //});

                var temp = [];
                for (var i = 0; i < $OperatingProcedures.length; i++) {
                    temp.push($OperatingProcedures[i]);
                }
                for (var i = 0; i < temp.length; i++) {
                    if (delIDs.includes(temp[i].id)) {
                        $OperatingProcedures.splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/OperatingProcedures/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($OperatingProcedures.EquipmenFacilities.length == 0) {
                        $OperatingProcedures.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var JobSteps = p.model.JobSteps;
                    var JobTask = p.model.JobTask;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    var TreeNode = p.model.TreeNode;

                    //分页
                    var offset = p.offset;
                    var limit = p.limit;

                    var limitUsers2 = [];
                    for (var i = 0; i < $OperatingProcedures.EquipmenFacilities.length; i++) {
                        var user = $OperatingProcedures.EquipmenFacilities[i];
                        if (JobSteps && user.JobSteps.indexOf(JobSteps) == -1)
                            continue;
                        if (JobTask && user.JobTask.indexOf(JobTask) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);
                        limitUsers2.push(user);
                    }
                   var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/OperatingProcedures/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$OperatingProcedures.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/OperatingProcedures/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$OperatingProcedures.EquipmenFacilities;
                var cz = true;
             
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].JobSteps = thisuser.JobSteps;
                        thisUsers[i].JobTask = thisuser.JobTask;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$OperatingProcedures.EquipmenFacilities.push({
                        id: thisuser.id,
                        JobSteps: thisuser.JobSteps,
                        JobTask: thisuser.JobTask,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $OperatingProcedures.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                JobSteps: randomValue('21'),
                JobTask: randomValue('24'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}

//< !--操作及相关作业活动列表-->
var $OperationRelatedActivities = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/OperationRelatedActivities/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                   var temp = [];
                for (var i = 0; i < $OperationRelatedActivities.EquipmenFacilities .length; i++) {
                    temp.push($OperationRelatedActivities.EquipmenFacilities [i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $OperationRelatedActivities.EquipmenFacilities .splice(temp[i], 1);
                    }
                }
               return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/OperationRelatedActivities/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($OperationRelatedActivities.EquipmenFacilities.length == 0) {
                        $OperationRelatedActivities.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var JobSteps = p.model.JobSteps;
                    var JobTask = p.model.JobTask;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    var TreeNode = p.model.TreeNode;
                    
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;

                    var limitUsers2 = [];
                    for (var i = 0; i < $OperationRelatedActivities.EquipmenFacilities.length; i++) {
                        var user = $OperationRelatedActivities.EquipmenFacilities[i];
                        if (JobSteps && user.JobSteps.indexOf(JobSteps) == -1)
                            continue;
                        if (JobTask && user.JobTask.indexOf(JobTask) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);
                        limitUsers2.push(user);
                    }

                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/OperationRelatedActivities/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$OperationRelatedActivities.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/OperationRelatedActivities/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$OperationRelatedActivities.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].JobSteps = thisuser.JobSteps;
                        thisUsers[i].JobTask = thisuser.JobTask;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].RequirementsComply = thisuser.RequirementsComply;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$OperationRelatedActivities.EquipmenFacilities.push({
                        id: thisuser.id,
                        JobSteps: thisuser.JobSteps,
                        JobTask: thisuser.JobTask,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        RequirementsComply: thisuser.RequirementsComply,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $OperationRelatedActivities.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                JobSteps: randomValue('21'),
                JobTask: randomValue('24'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                RequirementsComply: Mock.mock('@cparagraph(1, 1)'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}


//< !--场所环境列表-->
var $PlaceEnvironment = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/PlaceEnvironment/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                var temp = [];
                for (var i = 0; i < $PlaceEnvironment.EquipmenFacilities.length; i++) {
                    temp.push($PlaceEnvironment.EquipmenFacilities[i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $PlaceEnvironment.EquipmenFacilities.splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/PlaceEnvironment/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($PlaceEnvironment.EquipmenFacilities.length == 0) {
                        $PlaceEnvironment.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var PlaceEnvironmentName = p.model.PlaceEnvironmentName;
                    var EnergySource = p.model.EnergySource;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var TreeNode = p.model.TreeNode;
                    
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;
                    var limitUsers2 = [];
                    for (var i = 0; i < $PlaceEnvironment.EquipmenFacilities.length; i++) {
                        var user = $PlaceEnvironment.EquipmenFacilities[i];
                        if (PlaceEnvironmentName && user.PlaceEnvironmentName.indexOf(PlaceEnvironmentName) == -1)
                            continue;
                        if (EnergySource && user.EnergySource.indexOf(EnergySource) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);

                        limitUsers2.push(user);
                    }
                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/PlaceEnvironment/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$PlaceEnvironment.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/PlaceEnvironment/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$PlaceEnvironment.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].PlaceEnvironmentName = thisuser.PlaceEnvironmentName;
                        thisUsers[i].EnergySource = thisuser.EnergySource;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$PlaceEnvironment.EquipmenFacilities.push({
                        id: thisuser.id,
                        PlaceEnvironmentName: thisuser.PlaceEnvironmentName,
                        EnergySource: thisuser.EnergySource,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $PlaceEnvironment.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                PlaceEnvironmentName: randomValue('CSHJ'),
                EnergySource: randomValue('NENGLIANGYUAN'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}



//<!--工艺介质列表-->
var $ProcessMedium = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/ProcessMedium/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                var temp = [];
                for (var i = 0; i < $ProcessMedium.EquipmenFacilities .length; i++) {
                    temp.push($ProcessMedium.EquipmenFacilities [i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $ProcessMedium.EquipmenFacilities .splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/ProcessMedium/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($ProcessMedium.EquipmenFacilities.length == 0) {
                        $ProcessMedium.InitArray();
                    }
              
                    var p = JSON.parse(options.body);
                    //条件
                    var FeatureCharacteristics = p.model.FeatureCharacteristics;
                    var GuideWord = p.model.GuideWord;
                    var Deviation = p.model.Deviation;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    var TreeNode = p.model.TreeNode;
                    
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;
                    var limitUsers2 = [];
                    for (var i = 0; i < $ProcessMedium.EquipmenFacilities.length; i++) {
                        var user = $ProcessMedium.EquipmenFacilities[i];
                        if (FeatureCharacteristics && user.FeatureCharacteristics.indexOf(FeatureCharacteristics) == -1)
                            continue;
                        if (GuideWord && user.GuideWord.indexOf(GuideWord) == -1)
                            continue;
                        if (Deviation && user.Deviation.indexOf(Deviation) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);
                        limitUsers2.push(user);
                    }

       
                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }

                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };

                }); break;
            ////获取Input数据
            case '/api/ProcessMedium/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$ProcessMedium.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/ProcessMedium/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$ProcessMedium.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].FeatureCharacteristics = thisuser.FeatureCharacteristics;
                        thisUsers[i].GuideWord = thisuser.GuideWord;
                        thisUsers[i].Deviation = thisuser.Deviation;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$ProcessMedium.EquipmenFacilities.push({
                        id: thisuser.id,
                        FeatureCharacteristics: thisuser.FeatureCharacteristics,
                        GuideWord: thisuser.GuideWord,
                        Deviation: thisuser.Deviation,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $ProcessMedium.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                FeatureCharacteristics: randomValue('YSTX'),
                GuideWord: randomValue('YINDAOCI'),
                Deviation: randomValue('PIANCHA'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}

//<!--作业活动列表-->
var $WorkAtivities = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/WorkAtivities/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;
                var temp = [];
                for (var i = 0; i < $WorkAtivities.EquipmenFacilities .length; i++) {
                    temp.push($WorkAtivities.EquipmenFacilities [i]);
                }
                for (var i = 0; i < temp.length; i++) {
                    if (delIDs.includes(temp[i].id)) {
                        $WorkAtivities.EquipmenFacilities .splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/WorkAtivities/GetList': Mock.mock(host + url, type,
                function (options) {
                    if ($WorkAtivities.EquipmenFacilities.length == 0) {
                        $WorkAtivities.InitArray();
                    }
                    var p = JSON.parse(options.body);
                    //条件
                    var JobSteps = p.model.JobSteps;
                    var JobTask = p.model.JobTask;
                    var Risk = p.model.Risk;
                    var HazardousFactors = p.model.HazardousFactors;
                    var ControlRequirement = p.model.ControlRequirement;
                    
                    var TreeNode = p.model.TreeNode;
                    var RiskLevel = getDicValue("03", p.model.RiskLevel);
                    //分页
                    var offset = p.offset;
                    var limit = p.limit;

                    var limitUsers2 = [];
                    for (var i = 0; i < $WorkAtivities.EquipmenFacilities.length; i++) {
                        var user = $WorkAtivities.EquipmenFacilities[i];
                        if (JobSteps && user.JobSteps.indexOf(JobSteps) == -1)
                            continue;
                        if (JobTask && user.JobTask.indexOf(JobTask) == -1)
                            continue;
                        if (Risk && user.Risk.indexOf(Risk) == -1)
                            continue;
                        if (HazardousFactors && user.HazardousFactors.indexOf(HazardousFactors) == -1)
                            continue;
                        if (ControlRequirement && user.ControlRequirement.indexOf(ControlRequirement) == -1)
                            continue;
                        if (RiskLevel && user.RiskLevel.indexOf(RiskLevel) == -1)
                            continue;
                        if (TreeNode && user.TreeNode.indexOf(TreeNode) == -1)
                            continue;
                        
                        user.RiskLevel = getDicValue("03", user.RiskLevel) == '' ? user.RiskLevel : getDicValue("03", user.RiskLevel);


                        limitUsers2.push(user);
                    }

                    var limitUsers = [];
                    for (var i = 0; i < limitUsers2.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push(limitUsers2[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            ////获取Input数据
            case '/api/WorkAtivities/get': Mock.mock(host + url + '?' + param, type, function (options) {

                var myUsers = parent.$WorkAtivities.EquipmenFacilities;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                myuser.RiskLevel = getDicKey("03", myuser.RiskLevel);
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/WorkAtivities/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$WorkAtivities.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].JobSteps = thisuser.JobSteps;
                        thisUsers[i].JobTask = thisuser.JobTask;
                        thisUsers[i].Risk = thisuser.Risk;
                        thisUsers[i].HazardousFactors = thisuser.HazardousFactors;
                        thisUsers[i].ControlRequirement = thisuser.ControlRequirement;
                        thisUsers[i].RiskLevel = thisuser.RiskLevel;
                        thisUsers[i].TreeNode = thisuser.TreeNode;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$WorkAtivities.EquipmenFacilities.push({
                        id: thisuser.id,
                        JobSteps: thisuser.JobSteps,
                        JobTask: thisuser.JobTask,
                        Risk: thisuser.Risk,
                        HazardousFactors: thisuser.HazardousFactors,
                        ControlRequirement: thisuser.ControlRequirement,
                        RiskLevel: thisuser.RiskLevel,
                        TreeNode: thisuser.TreeNode,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $WorkAtivities.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                JobSteps: randomValue('21'),
                JobTask: randomValue('24'),
                Risk: randomValue('22'),
                HazardousFactors: randomValue('19'),
                ControlRequirement: randomValue('20'),
                RiskLevel: randomValue('03'),
                TreeNode: randomTreeNode(myTree)
            }));
        }
    }
}



//<!--风险类别管理列表-->
var $RiskCategoryManagement = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {
            ////删除
            case '/api/RiskCategoryManagement/DeleteMuti': Mock.mock(host + url, type, function (options) {
                var delIDs = options.body;

                var temp = [];
                for (var i = 0; i < $RiskCategoryManagement.EquipmenFacilities.length; i++) {
                    temp.push($RiskCategoryManagement.EquipmenFacilities[i]);
                }
                for (var i = 0; i < temp.length; i++) {

                    if (delIDs.includes(temp[i].id)) {
                        $System.Users.splice(temp[i], 1);
                    }
                }
                return { result: "Success", message: null, data: null };
            }); break;
            //获取List数据
            case '/api/RiskCategoryManagement/GetList': Mock.mock(host + url, type,
                function (options) {
                    var p = JSON.parse(options.body);
                    //条件

                    //分页
                    var offset = p.offset;
                    var limit = p.limit; 
                    var limitUsers = [];
                    for (var i = 0; i < $RiskCategoryManagement.length; i++) {
                        if (i < offset + limit && i >= offset) {
                            limitUsers.push($RiskCategoryManagement[i]);
                        }
                    }
                    return {
                        result: "Success", message: null,
                        data: { pageData: limitUsers, rowCount: limitUsers2.length }
                    };
                }); break;
            //获取Input数据
            case '/api/RiskCategoryManagement/get': Mock.mock(host + url + '?' + param, type, function (options) {
                var myUsers = parent.RiskCategoryaaa;
                myuser = {};
                for (var i = 0; i < myUsers.length; i++) {
                    if (myUsers[i].id == vueApp.id) {
                        myuser = myUsers[i];
                        break;
                    }
                }
                return {
                    result: "Success", message: null, data: myuser
                };
            }); break;
            ////提交
            case '/api/RiskCategoryManagement/Save': Mock.mock(host + url, type, function (options) {
                var thisuser = JSON.parse(options.body);
                var thisUsers = parent.$RiskCategoryManagement.EquipmenFacilities;
                var cz = true;
                for (var i = 0; i < thisUsers.length; i++) {
                    if (thisUsers[i].id == thisuser.id) {
                        thisUsers[i].name = thisuser.name;
                        thisUsers[i].code = thisuser.code;
                        thisUsers[i].remarks = thisuser.remarks;
                        cz = false;
                        break;
                    }
                }
                if (cz) {
                    //Input 页面需要 去操作List页面的数组 parent
                    parent.$RiskCategoryManagement.EquipmenFacilities.push({
                        id: thisuser.id,
                        name: thisuser.name,
                        code: thisuser.code,
                        remarks: thisuser.remarks,
                    });
                }
                return { result: "Success", message: null, data: null };
            }); break;
        }
    },
    EquipmenFacilities: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $RiskCategoryManagement.EquipmenFacilities.push(Mock.mock({
                id: Mock.Random.id(),
                name: Mock.Random.cname(),
                code: Mock.Random.cname(),
                remarks: Mock.mock('@cparagraph(1, 1)')
    
            }));
        }
    }
}

